<!--#include file="Config.asp" -->
<!--#include file="Header.asp" -->
<!--#include file="emp_is.asp"-->

<%
If request("fatherID")<>"" then
fatherID=int(request("fatherID"))
Else
fatherID=181
End if
%>

<table class="table">
	<tr>
		<th>
<form method="post" action="?Action=Add" class="form-panel">
<select name="fatherID" class="select btn-primary size-MINI radius">
<option value="0">0.顶级模块</option>
<%
sql="select * from basic_treeNav where fatherID=0 order by paixu"
rs.open sql,Conn,1,1
for m=1 to rs.recordcount
%>
<option value='<%=int(rs("ID"))%>' <%If fatherID=int(rs("ID")) then%>selected<%End if%>>
<%=m%>.<%=Trim(rs("name"))%>
</option>
<%
rs.moveNext
Next
rs.close
%>
</select>
<input type="text" name="name"   id="name" style="width:150px" placeholder="名称" class="input-text">
<input type="text" name="url"  value=""  placeholder="url" class="input-text" style="width:150px">
<span class="select-box inline">
<select name="URLTarget" class="select">
<option value="_self">_self</option>
<option value="_blank">_blank</option>
</select>

<input type="text" name="Comment" value="说明"  class="input-text" style="width:150px">
<span class="select-box inline">
<select name="isshow" class="select">
<option value="1" selected>显示</option>
<option value="0">不显示</option>
</select>

排序<input type="text" name="paixu" value="10" class="input-text" style="width:50px">
<input type="submit" name="Submit" value="添加" class="btn btn-default radius">
</form>

</td>
	</tr>
</table>

<table class="table">
	<tr>
		<th width="180" valign='top'>
<a href="?fatherID=0"">0. 全部模块</a><br>



<%
sql="select * from basic_treeNav where fatherID=0 order by paixu"
rs.open sql,Conn,1,1
for m=1 to rs.recordcount
%>
<a href="?fatherID=<%=int(rs("ID"))%>" ><%=int(rs("paixu"))%>.<%=int(rs("ID"))%>.<%=Trim(rs("name"))%></a><br>
<%
rs.moveNext
Next
rs.close
%>

</td>
<td valign='top'>

<table class="table">
<thead>
<tr>

<th>ID</th>
<th>Edit/Fatherid/paixu/点击修改</th>
<th>URL</th>
<th>iconCls</th>
<th>Target</th>
<th>Comment</th>
<th>isshow</th>
<th>DEL</th>
</TR>
</thead>
<tbody>

<!-- 开启多选模式 -->
<form name="frm"  method="post" action="?fatherID=<%=fatherID%>">
<%
If fatherID=0 then
sql="select * from basic_treeNav where fatherID="&fatherID&" order by paixu"
else
sql="select * from basic_treeNav where ID="&fatherID&" order by paixu"
End if
rs.open sql,Conn,1,1
r_f_count=rs.recordcount
for r_f=1 To r_f_count
s_fatherID=int(rs("id"))
s_URL=Trim(rs("URL"))
%>
<tr class="text-l">
<TD><input name="allbox" type="checkbox" onClick="CA();" title="选中全部小类">全选</TD>
<TD>
<A HREF="_MenuEdit.asp?EditMenuID=<%=Trim(rs("id"))%>" target='_blank' class="easyui-linkbutton"  data-options="iconCls:'<%=Trim(rs("iconCls"))%>'">【<%=Trim(rs("name"))%>】<%=rs("id")%>/<%=rs("Fatherid")%>/<%=Trim(rs("paixu"))%></A></TD>
<td ><font  color="#FF0000"><%=s_URL%></font></TD>
<td ><%=Trim(rs("iconCls"))%></TD>
<td ><%=Trim(rs("URLTarget"))%></TD>
<TD><%=Trim(rs("comment"))%></TD>
<TD><a href="?EditMenuID=<%=int(rs("id"))%>&Action=ShowMod"><%If Int(rs("isshow"))=0 then%><span class="label label-danger">不显示<%else%>在显示<%End if%></a></TD>
<TD><a href="?EditMenuID=<%=int(rs("id"))%>&Action=Del" title='删除一级类,其所属二级类也一并删除'>删除</a></TD>
</tr>
<%
'二级菜单开始
sqls="select * from basic_treeNav where FatherID='"&s_fatherID&"' order by paixu"
RSS.open sqls,Conn,1,1
r_s_count=RSS.recordcount
for r_s=1 to r_s_count
ID=int(RSS("id"))
ss_url=Trim(rss("URL"))

%>
<tr>
<TD ><input name="IDList" value="<%=ID%>" type="checkbox" title="选中每一条记录" ></TD>
<TD>
<A HREF="_MenuEdit.asp?EditMenuID=<%=ID%>" title='<%=Trim(RSS("name"))%>' target='_blank' class="easyui-linkbutton"  data-options="iconCls:'<%=Trim(rss("iconCls"))%>'"><B><%=Trim(RSS("name"))%></B>.<%=Trim(RSS("paixu"))%></A></TD>
<td ><a href="<%=ss_url%>" target='_blank'><%=ss_url%></a></TD>
<td ><%=Trim(RSS("iconCls"))%></TD>
<td ><%=Trim(RSS("URLTarget"))%></TD>
<TD><%=Trim(RSS("Comment"))%></TD>
<TD><a href="?EditMenuID=<%=ID%>&Action=ShowMod"><%If Int(rss("isshow"))=0 then%><span class="label label-danger">不显示<%else%><span >在显示<%End if%></A></TD>
<TD><a href="?EditMenuID=<%=ID%>&Action=Del">删除</A></TD>
</tr>


<%
RSS.moveNext
Next
RSS.close

rs.MoveNext
Next
'End If
rs.close
%>
</tbody>

<tr>
	<th colspan='20'>

<select name="TypeBatch" class="btn btn-primary radius size-MINI">
<option value="2" selected>批量移动至</option>
<option value="1">批量增加至</option>
<option value="3">批量IsShow</option>
</select>
<select name="SelFatherID" class="btn btn-primary radius size-MINI">
<%
sql="select * from basic_treeNav where fatherID=0 order by paixu"
rs.open sql,Conn,1,1
for m=1 to rs.recordcount
%>
<option value='<%=int(rs("ID"))%>' <%If fatherID=int(rs("ID")) then%>selected<%End if%>>
<%=m%>.<%=Trim(rs("name"))%>
</option>
<%
rs.moveNext
Next
rs.close
%>
</select>
<input type="submit" value='批量操作' class="btn btn-primary radius size-MINI">
共<%=r_s_count%>条二级记录！
</form>
	</td>
</tr>
</Table>


</td>
	</tr>
</table>

<%
'SQL Precess
Action=request("Action")
SelFatherID=request("SelFatherID")
TypeBatch=int(request("TypeBatch")) 'TypeBatch批量处理模式1=批量增加2=批量移动
'Add New Record
If Action="Add" then
sql= "SELECT * FROM basic_treeNav WHERE (id is null)"
rs.open sql,Conn,1,3
rs.addnew
rs("name") =Trim(Request("name"))
rs("enname") =Trim(Request("enname"))
rs("iconname") =Trim(Request("iconname"))
rs("url") =Trim(Request("url"))
rs("fatherID") =CInt(Request("fatherID"))
rs("urltarget") =Trim(Request("urltarget"))
rs("comment") =Trim(Request("comment"))
rs("isshow") =Trim(Request("isshow"))
rs("paixu") =Trim(Request("paixu"))
rs.Update
rs.close
set conn=nothing
response.redirect Request.ServerVariables("Http_referer")
'response.redirect "menuadmin.asp"
End If

'Modify Record
If Action="Mod" Then
EditMenuID=Int(request("EditMenuID"))
sql= "SELECT * FROM basic_treeNav WHERE id="&EditMenuID
rs.open sql,Conn,1,3
rs("name") =Trim(Request("name"))
rs("enname") =Trim(Request("enname"))
rs("iconname") =Trim(Request("iconname"))
rs("url") =Trim(Request("url"))
rs("fatherID") =CInt(Request("fatherID"))
rs("urltarget") =Trim(Request("urltarget"))
rs("comment") =Trim(Request("comment"))
rs("isshow") =Trim(Request("isshow"))
rs("paixu") =Trim(Request("paixu"))
rs.Update
rs.close
response.redirect Request.ServerVariables("Http_referer")
'response.redirect "menuadmin.asp"
End If

'ShowMod Record
If Action="ShowMod" Then
EditMenuID=Int(request("EditMenuID"))
sql= "UPDATE basic_treeNav SET IsShow=1-IsShow WHERE id="&EditMenuID
conn.execute (sql)
response.redirect Request.ServerVariables("Http_referer")
'response.redirect "GuideMenuAdmin.asp"
End If

'IsSetting Record
If Action="IsSetting" Then
EditMenuID=Int(request("EditMenuID"))
sql= "UPDATE basic_treeNav SET IsSetting=1-IsSetting WHERE id="&EditMenuID
conn.execute (sql)
response.redirect Request.ServerVariables("Http_referer")
'response.redirect "GuideMenuAdmin.asp"
End If

'Delete Record
If Action="Del" Then
EditMenuID=Int(request("EditMenuID"))
'删除自身
conn.execute ("delete FROM basic_treeNav WHERE id="&EditMenuID&" ")
'删除父级以及其子类
conn.execute ("delete FROM basic_treeNav WHERE Fatherid="&EditMenuID&" ")
set conn=nothing
response.redirect Request.ServerVariables("Http_referer")
'response.redirect "menuadmin.asp"
End If

'MulInsert Record
'TypeBatch=1 批量增加
If TypeBatch=1 And request("SelFatherID")<>"" Then
'1.接受IDList的ID值
cid = Split(request("IDList")&",",",")
'2.循环解析
for i=0 to UBound(cid)-1
'2.1.用SQL的Select出来对应ID的Name,URL，URLTarget
sql= "SELECT * FROM basic_treeNav WHERE id="&int(cid(i))
rs.open sql,Conn,1,1
Name=Trim(rs("name"))
url=Trim(rs("url"))
urltarget=Trim(rs("urltarget"))
rs.close
'2.2.Insert数据
Sql="INSERT  INTO  basic_treeNav(fatherID,Name,URL,URLTarget,paixu) VALUES   ('"&SelFatherID&"','"&Name&"','"&URL&"','"&URLTarget&"',10)"
conn.execute (Sql)
'response.write "" & Name & "<br>"
next
set conn=nothing
'response.redirect Request.ServerVariables("Http_referer")
response.redirect "?fatherID="&SelFatherID
End If

'MulMove Record
'TypeBatch=2 批量移动
If TypeBatch=2 And request("SelFatherID")<>"" Then
Sql="update basic_treeNav set fatherID='"&SelFatherID&"' where ID in("&request("IDList")&") "
conn.execute (Sql)
'response.write "" & request("IDList") & "<br>"
set conn=nothing
response.redirect "?fatherID="&SelFatherID
End If

'MulIsShow Record
'TypeBatch=3 批量设置Isshow
If TypeBatch=3 And request("SelFatherID")<>"" Then
Sql="UPDATE basic_treeNav SET IsShow=1-IsShow WHERE ID in("&request("IDList")&") "
conn.execute (Sql)
'response.write "" & request("IDList") & "<br>"
set conn=nothing
response.redirect "?fatherID="&SelFatherID
End If
%>

<!--#include file="Footer.asp" -->